function telJudge(phone) {
    var head1 = "";
    var head2 = "";
    var CMCC=1;//移动
    var UNICOM=2;//联通
    var TELECOM=3;//电信
    var UNKNOWN=4;//未知
    // 去除前后的空白
    phone = phone.trim();

    // 判断输入的电话号码是否合法
    if (phone == null || phone.length < 11) {
        console.log("电话号码不合法")
        return 0;//未知
    } else {
        // 处理国内的+86开头
        if (phone.startsWith("+")) {
            phone = phone.substring(1);
        }
        if (phone.startsWith("86")) {
            phone = phone.substring(2);
        }
    }
    // 去除+86后电话号码应为11位
    if (phone.length != 11) {
        console.log("电话号码不是11位")
        return 0;
    }
    // 判断去除+86后剩余的是否全为数字
    // if (!this.isNum(phone)) {
    //     console.log("电话号码包含非数字")
    //     return 0;
    // }
    // 截取前3或前4位电话号码，判断运营商
    head1 = phone.substring(0, 3);
    head2 = phone.substring(0, 4);

    // 移动前三位
    var cmcctemp3 = head1=="134"  || head1=="135" || head1=="136" ||
        head1=="137" || head1=="138" ||
        head1=="139" || head1=="147" ||
        head1=="150" || head1=="151" ||
        head1=="152" || head1=="157" ||
        head1=="158" || head1=="159" ||
        head1=="182" || head1=="183" ||
        head1=="184" || head1=="178" ||
        head1=="187" || head1=="188";
    if (cmcctemp3) {
        return CMCC;
    }
    // 移动前4位
    var cmcctemp4 = head2=="1340" || head2=="1341" ||
        head2=="1342" || head2=="1343" ||
        head2=="1344" || head2=="1345" ||
        head2=="1346" || head2=="1347" ||
        head2=="1348" || head2=="1705";
    if (cmcctemp4) {
        return CMCC;
    }
    // 联通前3位
    var unicomtemp = head1=="130" || head1=="131" ||
        head1=="132" || head1=="145" ||
        head1=="155" || head1=="156" || head1=="176" ||
        head1=="185" || head1=="186";
    if (unicomtemp) {
        return UNICOM;
    }
    //unicom 4
    var unicomtemp4 = head1=="1709";
    if (unicomtemp4) {
        return UNICOM;
    }
    // 电信前3位
    var telecomtemp = head1=="133" || head1=="153" ||
        head1=="181" || head1=="177" ||
        head1=="180" || head1=="189";

    if (telecomtemp) {
        return TELECOM;
    }
    //telecom 4
    var telecomtemp4 = head1=="1700";
    if (telecomtemp4) {
        return TELECOM;
    }

    return 0;
}
export default telJudge;